@extends('admin.layout')
@section('title','直播/录播列表')
@section('content')
        <div class="col-md-12" id="content">
            <div class="app_content_div" id="app_content_div_301Index">
                <h3>直播/录播列表</h3>
            </div>

            <div>
                <div style="float:right;">
                    <button type="button" class="btn btn-primary" onclick="window.location.href='/admin/video/add'">新增视频</button>
                </div>
            </div>
            <table class="table table-striped">
                <thead>
                <tr>
                    <th>id</th>
                    <th>标题</th>
                    <th>科室</th>
                    <th>专家</th>
                    <th>类型</th>
                    <th>直播开始时间</th>
                    <th>直播结束时间</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                @foreach($videos as $v)
                    <tr>
                        <th scope="row">{{$v->id}}</th>
                        <td>{{$v->title}}</td>
                        @if(isset($v->middle[0]))
                        <td>{{$v->middle[0]->department}}</td>
                        <td>{{$v->middle[0]->name}}</td>
                        @else
                            <td> </td>
                            <td> </td>
                        @endif
                        @if($v->type==1)
                            <td>直播</td>
                        @else
                            <td>录播</td>
                        @endif
                        <td>{{$v->start_at}}</td>
                        <td>{{$v->end_at}}</td>
                        <td>
                        <a href="/admin/video/edit/{{$v->id}}"><span class="glyphicon glyphicon-edit" aria-hidden="true"></span></a> &nbsp;&nbsp;&nbsp;
                        <a href="#" onclick="delVideo('/admin/video/delete/{{$v->id}}')"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span></a>
                    </td>
                    </tr>
                @endforeach
                </tbody>
            </table>
            {{$videos->links('paginate')}}
            <script>
                function delVideo(url){
                    if(confirm('确定要删除该条记录吗？')){
                        window.location.href = url;
                    }
                }
            </script>
        </div>
@endsection
